<template>

  <div id="addCategory" class="addCategory">
    <!-- header -->
    <yd-navbar slot="navbar" fixed>
      <a @click="$router.go(-1)" slot="left">
        <yd-navbar-back-icon></yd-navbar-back-icon>
      </a>
      <span slot="center" style="font-size:18px">添加分类</span>
    </yd-navbar>

    <!-- content -->
    <div class="content-addCategory" fixed>

      <yd-cell-group>
        <yd-cell-item>
          <span slot="left">父类ID：</span>
          <select slot="right" v-model.trim="parentId">
            <option value="0"> 请选择父类ID：</option>
            <option value="2">服装</option>
            <option value="3">鞋帽配饰</option>
            <option value="4">日化护肤</option>
            <option value="5">美妆</option>
            <option value="6">宠物</option>
            <option value="7">数码</option>
            <option value="8">家电</option>
            <option value="9">图书</option>
            <option value="10">影音</option>
            <option value="11">休闲食品</option>
            <option value="12">创意</option>
            <option value="13">其他</option>
          </select>
          
        </yd-cell-item>
        <yd-cell-item>
          <span slot="left">添加分类名：</span>
          <yd-input slot="right" required v-model.trim="categoryName" max="20" :showSuccessIcon="false"></yd-input>
        </yd-cell-item>
      </yd-cell-group>
      <yd-button size="large" @click.native="add" bgcolor="#2196f3" color="#fff">添加</yd-button>
    </div>
  </div>
</template>

<script>
  import axios from '../../axios'
  import baseService from '../../axios/'
  export default {
    name: 'addCategory',
    data() {
      return {
        message: '添加分类',
        parentId: '0',
        categoryName: ''
      }
    },
    methods: {
      add: function () {
        let param = new URLSearchParams();
        let parentId = this.parentId;
        let categoryName = this.categoryName;
        param.append("parentId", parentId);
        param.append("categoryName", categoryName);
        baseService.post('/manage/category/addCategory.do', param).then((res) => {
          // this.msg = res.data.msg;
          if (res.data.status == 10) {
            this.$dialog.alert({
              mes: res.data.msg
            });
            this.$router.push({
              path: '/user/login'

            })
          }
          else{
            this.$dialog.alert({
              mes: res.data.msg
            });
          }
        })
      }


    }
  }

</script>

<style>
  .addCategory .content-addCategory {
    position: fixed;
    padding-top: 15%;
    height: 100%;
    width: 100%;
    overflow-y: auto !important;
  }


</style>
